package org.evej.apiparser.parser.handler.account;

import org.evej.apiparser.model.account.ApiAccount;
import org.evej.apiparser.parser.handler.ApiDocumentHandler;

import org.xml.sax.SAXException;

public class AccountHandler extends ApiDocumentHandler<ApiAccount> {

    private ApiAccount.Builder accountBuilder = new ApiAccount.Builder();

    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {
        switch (qName) {
            case "logonMinutes" :
                accountBuilder.setLogonMinutes(elementContentToInt());
                break;
            case "logonCount" :
                accountBuilder.setLogonCount(elementContentToInt());
                break;
            case "paidUntil" :
                accountBuilder.setPaidUntil(getDate());
                break;
            case "createDate" :
                accountBuilder.setCreateDate(getDate());
                break;
        }
        super.endElement(uri, localName, qName);
    }

    @Override
    public void endDocument() throws SAXException {
        super.documentModel = accountBuilder.build();
        super.endDocument();
    }

}
